Add validation to only allow Cassandra major version 3#321
Add validation to only allow Cassandra major version 3#321jetstack-bot merged 9 commits intojetstack:masterfrom
Conversation
|
/retest |
| case versionSpecGe: | ||
| if v.LessThan(opVersion) { | ||
| return false | ||
| } |
There was a problem hiding this comment.
Can we invert the implementation here?
i.e. versionSpecGe should run v.Greater and v.Equal and return true
There was a problem hiding this comment.
I deleted this code and instead use github.com/hashicorp/go-version constraints.
| if opVersion.Equal(v) { | ||
| return false | ||
| } | ||
| if opVersion.LessThan(v) { |
There was a problem hiding this comment.
We switch to testing opVersion instead of v here - can we be consistent for readability?
There was a problem hiding this comment.
I deleted this code and instead use github.com/hashicorp/go-version constraints.
| for op, opVersion := range vs { | ||
| out = append(out, fmt.Sprintf("%s %s", op, opVersion)) | ||
| } | ||
| return strings.Join(out, ", ") |
There was a problem hiding this comment.
Maps are not consistently ordered, so this version string will be unstable. Can we make it stable?
There was a problem hiding this comment.
I deleted this code and instead use github.com/hashicorp/go-version constraints.
| versionSpecLt: version.New("4.0.0"), | ||
| } | ||
|
|
||
| func (vs versionSpec) Check(v *version.Version) bool { |
There was a problem hiding this comment.
Maybe a quick unit test for this function?
There was a problem hiding this comment.
Switched to github.com/hashicorp/go-version constraints which already has unit tests.
9af030e to
f284870
Compare
|
Hey @munnerz. Please take another look.
I can follow this up with PRs to
|
|
/retest |
| if err != nil { | ||
| return err | ||
| } | ||
| v.versionString = s |
There was a problem hiding this comment.
Do we need to keep the versionString in memory? Surely semver.String will be more up to date?
There was a problem hiding this comment.
We need it because we want to remember the format of the originally supplied version string.
So if the Cassandra node reports version 3.11 via nodetool and a JMX query, we want to report that exact version in the Pilot.Status.Cassandra.Version rather than the semver 3.11.0.
We also don't want a user to submit CassandraCluster.Spec.Version: 3.11 and then have that change to 3.11.0 when they do kubectl get CassandraCluster -o yaml.
However, when we infer the Docker image tag, we use the semver, because we don't want docker to simply pull the latest 3.11 image from Dockerhub.
| "github.com/coreos/go-semver/semver" | ||
| semver "github.com/hashicorp/go-version" | ||
| ) | ||
|
|
There was a problem hiding this comment.
Can we move this file out of pkg/cassandra and into something like pkg/api/util? This is an API type, but it isn't by default part of an API group (hence it isn't in apis).
It'd be good to denote it as such in the file structure, to make it clear this isn't specific to just cassandra (and also denotes that this type may be exposed in an api)
| t.Run( | ||
| "zero value", | ||
| func(t *testing.T) { | ||
| t.Log(version.Version{}.DeepCopy()) |
There was a problem hiding this comment.
This doesn't test anything, or ever fail afaict
There was a problem hiding this comment.
It tests that a Zero value can be DeepCopied.
It originally caused a panic before I added a check for nil pointer in the implementation.
I'll leave it for now.
| if v.semver == nil { | ||
| return Version{} | ||
| } | ||
| return *New(v.String()) |
Gopkg.toml
Outdated
|
|
||
| [[constraint]] | ||
| branch = "master" | ||
| name = "github.com/hashicorp/go-version" |
There was a problem hiding this comment.
Don't think this needs to be added as a constraint given we are constraining it to master anyway. A simple dep ensure without adding this block should yield the same result, sans this change
|
/retest |
|
The navigator-e2e-v1-9 E2E test failure was a flake, described here: jetstack/test-infra#180 |
|
/lgtm |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: munnerz The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Fixes: #320
Release note: